# -*- coding:utf-8 -*-

import os
from lxml import etree

from csv2code import ParseError

class Parser(object):
	@property
	def name(self):
		return 'metaparser for xml'
	
	def _meta_file(self, csv_file):
		if not os.path.exists(csv_file):
			raise ParseError('%s is not found.'%csv_file)
		root, ext = os.path.splitext(csv_file)
		meta_file = '.'.join([root, 'csv2code.xml'])
		if not os.path.exists(meta_file):
			raise ParseError('%s is not found.'%meta_file)
		return meta_file

	def process(self, csv_file, include_dirs):
		meta_file = self._meta_file(csv_file)
		t = None
		with open(meta_file) as meta:
			t = etree.parse(meta)
		print t	

